package com.tmxk.api.days02.zjq;

import com.sun.xml.internal.ws.api.model.wsdl.WSDLOutput;

import javax.crypto.spec.PSource;
import java.util.*;

/**
 * @BelongsProject: java-api1
 * @BelongsPackage: com.tmxk.api.days02.zjq
 * @Author: zjq
 * @CreateTime: 2022-11-29  16:38
 * @Description: TODO
 * @Version: 1.0
 */
public class StringDemo {
    static Map<String,User> userMap =  new HashMap<>();
    static{
        User user1 = new User("1","zz","123");
        User user2 = new User("2","zza","1233");
        userMap.put(user1.getUserId(),user1);
        userMap.put(user2.getUserId(),user2);
    }

    public static void main(String[] args) {
        //登录：用户名，密码
        Scanner sc = new Scanner(System.in);
        System.out.println("请登录");
        System.out.print("请输入用户名:");
        String userName = sc.next();
        System.out.print("请输入密码:");
        String password = sc.next();
        Collection<User> users = userMap.values();
        for (User u : users) {
            if (userName.equals(u.getUserName()) && password.equals(u.getPassword())) {
                System.out.println("登录成功");
                break;
            } else {
                System.out.println("登录失败,请重新登录");
            }
        }
    }
}

